import time,threading
####

class AnoleError(Exception):
	pass
class NetworkError(AnoleError):
	pass
class NotImpError(AnoleError):
    def __init__(self,obj,funcName):
        str="object %s 's function %s is not implemented"%(str(obj),funcName)
        self.args=str



class AnoleLog:
    LEVEL_ERROR=5
    LEVEL_WARNING=4
    LEVEL_INFO=3
    LEVEL_DEBUG=2
    LEVEL_NOTSET=1
    ERROR_STR={LEVEL_ERROR:'[ERROR]',
               LEVEL_WARNING:'[WARNING]',
               LEVEL_INFO:'[INFO]',
               LEVEL_DEBUG:'[DEBUG]',
               
        }
    level=LEVEL_NOTSET
    def __init__(self,tmEnabled=True,thEnabled=True):
	self._tmEnabled=tmEnabled
	self._thEnabled=thEnabled

    def log(self,str,level):
        if level<self.level:
            return
	_prefix=self.ERROR_STR[level]
	if self._tmEnabled:
		tmStr=time.ctime()[:-4]
		_prefix+='['+tmStr+']'
	if self._thEnabled:
		thName=threading.currentThread().getName()
		_prefix+='['+thName+']'
        print _prefix+str

#__all__ = ['core','test','utils','draft']
__author__="devdoer"
__email__="devdoer@gmail.com"
__licence__="GPL"
#version_info = (0,,5)
#__version__ = "0.6.5"        


